<!--
 * @Descripttion: 
 * @version: 
 * @Author: siebe
 * @Date: 2022-02-17 01:19:44
 * @LastEditors: siebe
 * @LastEditTime: 2022-02-20 23:05:01
-->
<!DOCTYPE html>
<html lang="zh-CN">

<head>
	<meta charset="utf-8">
	<title>后台管理系统</title>
	<meta name="renderer" content="bew">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport"
		content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css">
	<link rel="stylesheet" type="text/css" href="/static/admin/css/login.css">
	<script type="text/javascript" src="/static/layui/layui.js"></script>
</head>

<body>
	<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login">
		<div class="layadmin-user-login-main">
			<div class="layadmin-user-login-box layadmin-user-login-header">
				<img src="/static/admin/images/logo.jpg" />
				<h2>后台管理系统</h2>
			</div>
			<div class="layadmin-user-login-box layadmin-user-login-body layui-form">
				<form class="layui-form login-form">
					<div class="layui-form-item">
						<label class="layadmin-user-login-icon layui-icon layui-icon-username" for="account"></label>
						<input type="text" id="username" name="username" placeholder="用户名" class="layui-input"
							value="admin">
					</div>
					<div class="layui-form-item">
						<label class="layadmin-user-login-icon layui-icon layui-icon-password" for="password"></label>
						<input type="password" name="password" class="layui-input" placeholder="密码" class="layui-input"
							value="123456">
					</div>
					<div class="layui-form-item">
						<div class="layui-row">
							<div class="layui-col-xs7">
								<label class="layadmin-user-login-icon layui-icon layui-icon-vercode"
									for="code"></label>
								<input type="text" name="code" placeholder="图形验证码" class="layui-input">
							</div>
							<div class="layui-col-xs5">
								<div style="margin-left:10px;">
									<img src="{:captcha_src()}" alt="captcha" class="layadmin-user-login-codeimg"
										id="img" onclick="reloadImg()" />
								</div>
							</div>
						</div>
					</div>
					<div class="layui-form-item" style="margin-bottom: 20px;">
						<input type="checkbox" name="remember" lay-skin="primary" title="记住密码">
					</div>
				</form>
				<div class="layui-form-item">
					<button class="layui-btn layui-btn-fluid" onclick="login()">登 录</button>
				</div>
			</div>
		</div>
	</div>
</body>

</html>
<script type="text/javascript">
	layui.use(['layer', 'form'], function () {
		var form = layui.form;
		layer = layui.layer;
		$ = layui.jquery;
		// 用户名控件获取焦点
		$('#account').focus();
		// 回车登录
		$("input").keydown(function (e) {
			if (e.keyCode == 13) {
				login();
			}
		})
	});
	// 登录
	function login() {
		$.post("{$config.path}login/login", $('form').serialize(), function (res) {
			if(res.error_code == 0){
				layer.msg(res.msg, { 'icon': 1 });
				setTimeout(function () {
					parent.window.location.reload();
					window.location.href = "{$config.path}index/index";
				}, 1000);
			}else{
				layer.msg(res.msg, { 'icon': 2 });
				reloadImg();
			}
		}, 'json').error(function (res) {
			layer.msg(res.responseJSON.msg, { 'icon': 2 });
			reloadImg();
		});
	}
	// 重新生成验证码
	function reloadImg() {
		$('#img').attr('src', '{:captcha_src()}?rand=' + Math.random());
	}
</script>